package org.zoomdev.zoom.dao.adapters.result;

import org.zoomdev.zoom.dao.adapters.ResultSetAdapter;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.Year;

public class Date2YearResultSetAdapter implements ResultSetAdapter<Year> {
    @Override
    public Year getObject(ResultSet rs, int index) throws SQLException {
        Integer date = rs.getObject(index, Integer.class);
        if (date == null) {
            return null;
        }
        return Year.of(date);
    }
}